﻿<Window x:Class="RemoteTestRunner.FormsUI.Wpf.ProjectAdmin"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Project Administration" Height="512" Width="736" WindowStartupLocation="CenterScreen">
    <Window.Resources>
    	<SolidColorBrush x:Key="ListBorder" Color="#828790"/>
    	<Style x:Key="TreeViewStyle" TargetType="{x:Type TreeView}">
    		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
    		<Setter Property="BorderBrush" Value="LightSlateGray"/>
    		<Setter Property="BorderThickness" Value="2"/>
            <Setter Property="Margin" Value="1"/>
            <Setter Property="Padding" Value="1"/>
    		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    		<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
    		<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
    		<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
    		<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
    		<Setter Property="VerticalContentAlignment" Value="Center"/>
    		<Setter Property="Template">
    			<Setter.Value>
    				<ControlTemplate TargetType="{x:Type TreeView}">
    					<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true" CornerRadius="6,6,6,6">
                            <ScrollViewer x:Name="_tv_scrollviewer_" Background="{TemplateBinding Background}" Margin="{TemplateBinding Margin}" CanContentScroll="false" Focusable="false" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
    							<ItemsPresenter/>
    						</ScrollViewer>
    					</Border>
    					<ControlTemplate.Triggers>
    						<Trigger Property="IsEnabled" Value="false">
    							<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
    						</Trigger>
    						<Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true">
    							<Setter Property="CanContentScroll" TargetName="_tv_scrollviewer_" Value="true"/>
    						</Trigger>
    					</ControlTemplate.Triggers>
    				</ControlTemplate>
    			</Setter.Value>
    		</Setter>
    		<Style.Triggers>
    			<Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true">
    				<Setter Property="ItemsPanel">
    					<Setter.Value>
    						<ItemsPanelTemplate>
    							<VirtualizingStackPanel/>
    						</ItemsPanelTemplate>
    					</Setter.Value>
    				</Setter>
    			</Trigger>
    		</Style.Triggers>
    	</Style>
    	<BorderGapMaskConverter x:Key="BorderGapMaskConverter"/>
    	<Style x:Key="GroupBoxStyle" TargetType="{x:Type GroupBox}">
            <Setter Property="BorderBrush" Value="LightSlateGray"/>
    		<Setter Property="BorderThickness" Value="2"/>
            <Setter Property="Template">
    			<Setter.Value>
    				<ControlTemplate TargetType="{x:Type GroupBox}">
    					<Grid SnapsToDevicePixels="true">
    						<Grid.ColumnDefinitions>
    							<ColumnDefinition Width="6"/>
    							<ColumnDefinition Width="Auto"/>
    							<ColumnDefinition Width="*"/>
    							<ColumnDefinition Width="6"/>
    						</Grid.ColumnDefinitions>
    						<Grid.RowDefinitions>
    							<RowDefinition Height="Auto"/>
    							<RowDefinition Height="Auto"/>
    							<RowDefinition Height="*"/>
    							<RowDefinition Height="6"/>
    						</Grid.RowDefinitions>
    						<Border BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="4" Grid.Column="0" CornerRadius="4" Grid.Row="1" Grid.RowSpan="3"/>
    						<Border x:Name="Header" Grid.Column="1" Padding="3,1,3,0" Grid.Row="0" Grid.RowSpan="2">
    							<ContentPresenter ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    						</Border>
    						<ContentPresenter Grid.ColumnSpan="2" Grid.Column="1" Margin="{TemplateBinding Padding}" Grid.Row="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    						<Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="4" CornerRadius="4" Grid.Row="1" Grid.RowSpan="3">
    							<Border.OpacityMask>
    								<MultiBinding ConverterParameter="7" Converter="{StaticResource BorderGapMaskConverter}">
    									<Binding ElementName="Header" Path="ActualWidth"/>
    									<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}"/>
    									<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}"/>
    								</MultiBinding>
    							</Border.OpacityMask>
    							<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
    								<Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/>
    							</Border>
    						</Border>
    					</Grid>
    				</ControlTemplate>
    			</Setter.Value>
    		</Setter>
    	</Style>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions >
            <ColumnDefinition Width="250" />
            <ColumnDefinition Width="2*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions >
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TreeView 
            ItemsSource="{Binding Path=Projects}"
            Name="tvwProjects" 
            SelectedItemChanged="tvwProjects_SelectedItemChanged" Margin="4,10,4,2" Style="{DynamicResource TreeViewStyle}">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Tests}"   >
                    <HierarchicalDataTemplate.ItemContainerStyle>
                        <Style TargetType="TreeViewItem">
                            <Setter Property="IsExpanded" Value="True" />
                        </Style>
                    </HierarchicalDataTemplate.ItemContainerStyle>
                    <StackPanel Orientation="Horizontal" >
                        <Label Padding="0" Content="Project: " ></Label>
                        <Label Padding="0" Content="{Binding Name}" ></Label>
                    </StackPanel>
                    <HierarchicalDataTemplate.ItemTemplate >
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <Label Padding="0" Content="Test: " ></Label>
                                <Label Padding="0" Content="{Binding Name}"></Label>
                            </StackPanel>
                        </DataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
        <Grid Grid.Column="1">
            <Grid.RowDefinitions >
                <RowDefinition Height="Auto"  />
                <RowDefinition Height="Auto"  />
                <RowDefinition />
            </Grid.RowDefinitions>
            <GroupBox Header="Project Details" Style="{DynamicResource GroupBoxStyle}" Margin="0,0,2,0">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>

                    </Grid.RowDefinitions>
                    <Label Grid.Row="0">_Project Name:</Label>
                    <TextBox Grid.Column="1" Text="{Binding SelectedProject.Name}" Margin="0,2"></TextBox>
                </Grid>
            </GroupBox>
            <GroupBox Header="Test Details" Grid.Row="1" Style="{DynamicResource GroupBoxStyle}" Margin="0,0,2,0">
                <Grid>
                    <Grid.RowDefinitions >
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions >
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                        <ColumnDefinition Width="25" />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Row="0">Test _Name:</Label>
                    <TextBox Grid.Column="1" Text="{Binding SelectedTest.Name}" Margin="0,2,2,2"/>

                    <Label Grid.Row="1">Test _Assembly:</Label>
                    <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding SelectedTest.AssemblyPath}" Margin="0,2,2,2"></TextBox>
                    <Button Grid.Row="1" Grid.Column="2" Margin="0,2,2,2">...</Button>

                    <Label Grid.Row="2">Configuration _File:</Label>
                    <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding SelectedTest.ConfigPath}" Margin="0,2,2,2"></TextBox>
                    <Button Grid.Row="2" Grid.Column="2" Margin="0,2,2,0" Height="21.96" VerticalAlignment="Top">...</Button>

                    <Label Grid.Row="3">_Run Config File:</Label>
                    <TextBox Grid.Column="1" Grid.Row="3" Text="{Binding SelectedTest.RunConfigPath}" Margin="0,2,2,2"></TextBox>
                    <Button Grid.Row="3" Grid.Column="2" Margin="0,2,2,2" Height="21.96" VerticalAlignment="Bottom">...</Button>
                </Grid>
            </GroupBox>
            <GroupBox Grid.Row="2" Header="Data Sources" Style="{DynamicResource GroupBoxStyle}" Margin="0,0,2,0">
                <Grid>
                    <ListView BorderThickness="0"></ListView>
                </Grid>
            </GroupBox>
        </Grid>
        <StackPanel Grid.Row="1" Orientation="Vertical">
            <StackPanel Orientation="Horizontal" >
                <Button Margin="4,2,2,2" Command="{Binding AddProjectCommand}" CommandParameter="{Binding ElementName=tvwProjects, Path=SelectedItem}" Name="btnAddProject" Width="80">Add _Project</Button>
                <Button Margin="2" Command="{Binding AddTestCommand}" CommandParameter="{Binding ElementName=tvwProjects, Path=SelectedItem}" Name="btnAddTest" IsEnabled="False" Width="80">Add _Test</Button>
            </StackPanel>
            <StackPanel Orientation="Horizontal" >
                <Button Margin="4,2,2,2" Command="{Binding DeleteProjectCommand}" CommandParameter="{Binding ElementName=tvwProjects, Path=SelectedItem}" Name="btnDeleteProject" IsEnabled="False" Width="80">Delete P_roject</Button>
                <Button Margin="2" Command="{Binding DeleteTestCommand}" CommandParameter="{Binding ElementName=tvwProjects, Path=SelectedItem}" Name="btnDeleteTest" IsEnabled="False" Width="80">Delete T_est</Button>
            </StackPanel>
        </StackPanel>
        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Margin="2,2,4,2" Command="{Binding SaveCommand}" Width="80" Height="25" Content="OK" IsDefault="True"></Button>
            <Button Margin="2,2,4,2" Command="{Binding CancelCommand}" Width="80" Height="25" IsCancel="True">_Cancel</Button>
        </StackPanel>
    </Grid>
</Window>
